/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package GM.impl;

import GM.Agent;
import GM.Entity;
import GM.GMPackage;
import GM.Operation;

import java.util.Collection;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;

import org.eclipse.emf.ecore.util.EObjectResolvingEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Agent</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link GM.impl.AgentImpl#getOperat <em>Operat</em>}</li>
 *   <li>{@link GM.impl.AgentImpl#getRead <em>Read</em>}</li>
 *   <li>{@link GM.impl.AgentImpl#getWrite <em>Write</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class AgentImpl extends ObjectImpl implements Agent {
	/**
	 * The cached value of the '{@link #getOperat() <em>Operat</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getOperat()
	 * @generated
	 * @ordered
	 */
	protected EList<Operation> operat;

	/**
	 * The cached value of the '{@link #getRead() <em>Read</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getRead()
	 * @generated
	 * @ordered
	 */
	protected EList<Entity> read;

	/**
	 * The cached value of the '{@link #getWrite() <em>Write</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getWrite()
	 * @generated
	 * @ordered
	 */
	protected EList<Entity> write;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected AgentImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return GMPackage.Literals.AGENT;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Operation> getOperat() {
		if (operat == null) {
			operat = new EObjectResolvingEList<Operation>(Operation.class, this, GMPackage.AGENT__OPERAT);
		}
		return operat;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Entity> getRead() {
		if (read == null) {
			read = new EObjectResolvingEList<Entity>(Entity.class, this, GMPackage.AGENT__READ);
		}
		return read;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Entity> getWrite() {
		if (write == null) {
			write = new EObjectResolvingEList<Entity>(Entity.class, this, GMPackage.AGENT__WRITE);
		}
		return write;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case GMPackage.AGENT__OPERAT:
				return getOperat();
			case GMPackage.AGENT__READ:
				return getRead();
			case GMPackage.AGENT__WRITE:
				return getWrite();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case GMPackage.AGENT__OPERAT:
				getOperat().clear();
				getOperat().addAll((Collection<? extends Operation>)newValue);
				return;
			case GMPackage.AGENT__READ:
				getRead().clear();
				getRead().addAll((Collection<? extends Entity>)newValue);
				return;
			case GMPackage.AGENT__WRITE:
				getWrite().clear();
				getWrite().addAll((Collection<? extends Entity>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case GMPackage.AGENT__OPERAT:
				getOperat().clear();
				return;
			case GMPackage.AGENT__READ:
				getRead().clear();
				return;
			case GMPackage.AGENT__WRITE:
				getWrite().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case GMPackage.AGENT__OPERAT:
				return operat != null && !operat.isEmpty();
			case GMPackage.AGENT__READ:
				return read != null && !read.isEmpty();
			case GMPackage.AGENT__WRITE:
				return write != null && !write.isEmpty();
		}
		return super.eIsSet(featureID);
	}

} //AgentImpl
